package com.hexacta.hrs.test.data;

import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.vectrics.employee.Employee;

import com.hexacta.hrs.timeoff.AvailableLicenseDays;

/**
 * Test data dependency creator for the AvailableLicenseDays class.
 * 
 * @author tpollak
 */
public class AvailableLicenseDaysTestDataDependencyCreator extends AbstractTestDataDependencyCreator {

    public AvailableLicenseDaysTestDataDependencyCreator(List<TestDataDependencyCreator> dependencies) {
        super(dependencies);
    }

    public void createDependentTestData(Map<String, Object> context) {
        AvailableLicenseDays days1 = this.createAvailableLicenseDays(context,
                EmployeeTestDataDependencyCreator.EMPLOYEE_1);
        AvailableLicenseDays days2 = this.createAvailableLicenseDays(context,
                EmployeeTestDataDependencyCreator.EMPLOYEE_2);
        AvailableLicenseDays days3 = this.createAvailableLicenseDays(context,
                EmployeeTestDataDependencyCreator.EMPLOYEE_3);
        AvailableLicenseDays days4 = this.createAvailableLicenseDays(context,
                EmployeeTestDataDependencyCreator.EMPLOYEE_4);
        AvailableLicenseDays days5 = this.createAvailableLicenseDays(context,
                EmployeeTestDataDependencyCreator.EMPLOYEE_5);

        days1 = this.insertDomainObject(days1);
        days2 = this.insertDomainObject(days2);
        days3 = this.insertDomainObject(days3);
        days4 = this.insertDomainObject(days4);
        days5 = this.insertDomainObject(days5);
    }

    @Override
    public Set<Scenario> getApplicableScenarios() {
        return EnumSet.of(Scenario.DEVELOPMENT);
    }

    private AvailableLicenseDays createAvailableLicenseDays(Map<String, Object> context, String employeeToken) {
        Employee employee = (Employee) this.loadObjectFromContext(context, employeeToken);
        AvailableLicenseDays days = new AvailableLicenseDays();
        days.setEmployee(employee);
        days.setCompensationDays(Integer.valueOf(0));
        days.setCurrentPeriodVacationDays(Integer.valueOf(10));
        days.setStudyLicenseDays(Integer.valueOf(0));
        days.setPreviousPeriodsVacationDays(Integer.valueOf(0));
        days.setLastCalculationDate(this.getDataUtils().createCurrentDate());
        return days;
    }
}
